﻿function createWeightDetailTitleView(name, date, allDunWeight) {
    return new Ext.Panel({
        frame: true,
        anchor: '100% 20%',
        items: [{xtype: "label",text:"  "},
        {
            layout: { type: 'hbox' },
            border: false,
            bodyBorder: false,
            items: [
                                    {
                      
                                        width: 150,
                                        xtype: "label",
                                        text: name
                                    }, {
                               
                                        width: 150,
                                        xtype: "label",
                                        text: date
                                    }, {
                          
                                        width: 150,
                                        xtype: "label",
                                        text: allDunWeight
                                    }
                                    ]
        }
        ]
    });
}

/* ---处理厂-区详情---*/
function getFactoryWeightByDistrictJS(clientName,date, type, typeFactory) {
    var weightVehicleInfoNew = new Ext.data.Store({
        url: "../Json/JsonGetWeightInfoList.ashx",
        reader: new Ext.data.JsonReader(
                { root: 'data' },
                Ext.data.Record.create([{ name: 'name' }, { name: 'type' }, { name: 'dunCount' }, { name: 'dateAll' }, { name: 'weightAll'}])
            )
    });
    weightVehicleInfoNew.load({
        params: { clientName: clientName, dateString: dateChange(date), type: type, typeFactory: typeFactory, op: 'GetFactoryWeightByDistrict'}//日期、处理厂名称
                    , callback: function (records, options, success) {
                        if (success && records.length) {
                            newDistrictDetailWindow(this);
                        }
                    }
    });
}
function newDistrictDetailWindow(item) {

    var this_grid = new Ext.grid.GridPanel({
        anchor: '100% 80%',
        columns: [
	{ header: "处理厂名称", dataIndex: "name", width: 200 },
    { header: "处理厂类型", dataIndex: "type", width: 150 },
    {header: "处理吨数", dataIndex: "dunCount", width: 100 }
	],
        store: item
    });

    var panel = new Ext.Panel({
        //        layout: 'fit',
        //        items: this_grid
        layout: 'anchor',
        items: [createWeightDetailTitleView("名称：XX", "日期：2000年3月4日", "25869吨"), this_grid]
    });
    var window = new Ext.Window({
        title: '处理厂详情',
                layout: 'fit',       //弹出窗口内布局会充满整个窗口;
        
        width: 500,          //设置窗口大小;
        height: 300,
        items: panel
    });
    window.show();
}

/* ---处理厂-处理厂详情---*/
function getDistrictWeightByFactoryBhJS(date, nameFactory) {
    var weightVehicleInfoNew = new Ext.data.Store({
        url: "../Json/JsonGetWeightInfoList.ashx",
        reader: new Ext.data.JsonReader(
                { root: 'data' },
                Ext.data.Record.create([{ name: 'name' }, { name: 'dunCount' }, { name: 'dateAll' }, { name: 'weightAll'}])
            )
    });
    weightVehicleInfoNew.load({
        params: { dateString: dateChange(date), nameFactory: nameFactory, op: 'GetDistrictWeightByFactoryBh'}//日期、处理厂名称
                    , callback: function (records, options, success) {
                        if (success && records.length) {
                            newFactoryDetailWindow(this);
                        }
                    }
    });
}
function newFactoryDetailWindow(item) {
    var this_grid = new Ext.grid.GridPanel({
        anchor: '100% 80%',
        columns: [
	{ header: "地区", dataIndex: "name", width: 80 },
    {header: "处理吨数", dataIndex: "dunCount", width: 100 }
	],
        store: item
    });

    var panel = new Ext.Panel({
//        layout: 'fit',
//        items: this_grid
        layout: 'anchor',
        items: [createWeightDetailTitleView("名称：XX", "日期：2000年3月4日", "25869吨"), this_grid]
    });
    var window = new Ext.Window({
        title: '处理厂详情',
        layout: 'fit',       //弹出窗口内布局会充满整个窗口;
        width: 500,          //设置窗口大小;
        height: 300,
        items: panel         //默认会生成Ext.Panel类型的对象;并且随窗口大小改变而改变;
    });
    window.show();
}

/* ---按  处理厂  车辆详情---*/
function getVehicleWeightByFactoryJS(date, name) {
    var weightVehicleInfoNew = new Ext.data.Store({
        url: "../Json/JsonGetWeightInfoList.ashx",
        reader: new Ext.data.JsonReader(
                { root: 'data' },
                Ext.data.Record.create([{ name: 'name' }, { name: 'dunCount' }, { name: 'dateAll' }, { name: 'weightAll'}])
            )
    });
    weightVehicleInfoNew.load({
        params: { dateString: dateChange(date), nameFactory: name, op: 'GetVehicleWeightByFactory'}//区名、日期、中转站or处理厂、中转站类型or处理厂类型
                    , callback: function (records, options, success) {
                        if (success && records.length) {
                            newVehicleFactoryWeightWindow(this);
                        }
                    }
    });
}
function newVehicleFactoryWeightWindow(item) {
    var this_grid = new Ext.grid.GridPanel({
        columns: [
	{ header: "车辆名称", dataIndex: "name", width: 80 },
//    { header: "处理厂名称", dataIndex: "factoryName", width: 200 },
//	{ header: "处理厂类型", dataIndex: "factoryType", width: 100 },
    { header: "处理吨数", dataIndex: "dunCount", width: 100 }
	],
        store: item
    });

    var panel = new Ext.Panel({
        layout: 'fit',
        items: this_grid
    });
    var window = new Ext.Window({
        title: '车辆详情',
        layout: 'fit',       //弹出窗口内布局会充满整个窗口;
        width: 500,          //设置窗口大小;
        height: 300,
        items: panel         //默认会生成Ext.Panel类型的对象;并且随窗口大小改变而改变;
    });
    window.show();
}

 /* ---按  区  车辆详情---*/
function getVehicleWeightByDistrictJS(clientName, date, type, name) {
    var weightVehicleInfoNew = new Ext.data.Store({
        url: "../Json/JsonGetWeightInfoList.ashx",
        reader: new Ext.data.JsonReader(
                { root: 'data' },
                Ext.data.Record.create([{ name: 'name' }, { name: 'dunCount' }, { name: 'factoryName' }, { name: 'factoryType' }, { name: 'dateAll' }, { name: 'weightAll'}])
            )
    });
    weightVehicleInfoNew.load({
        params: { clientName: clientName, dateString: dateChange(date), type: type, name: name, op: 'GetVehicleWeightByDistrict'}//区名、日期、中转站or处理厂、中转站类型or处理厂类型
                    , callback: function (records, options, success) {
                        if (success && records.length) {
                            newVehicleDistrictWeightWindow(this);
                        }
                    }
    });
}
function newVehicleDistrictWeightWindow(item) {
    var this_grid = new Ext.grid.GridPanel({
        columns: [
	{ header: "车辆名称", dataIndex: "name", width: 80 },
    { header: "处理厂名称", dataIndex: "factoryName", width: 200 },
	{ header: "处理厂类型", dataIndex: "factoryType", width: 100 },
    { header: "处理吨数", dataIndex: "dunCount", width: 100 }
	],
        store: item
    });

    var panel = new Ext.Panel({
        layout: 'fit',
        items: this_grid
    });
    var window = new Ext.Window({
        title: '车辆详情',
        layout: 'fit',       //弹出窗口内布局会充满整个窗口;
        width: 500,          //设置窗口大小;
        height: 300,
        items: panel         //默认会生成Ext.Panel类型的对象;并且随窗口大小改变而改变;
    });
    window.show();
}

function dateChange(date) {
    date = date.replace("年", "-");
    date = date.replace("月", "-");
    date = date.replace("日", "");
    return date;
}   